package com.github.zzay.news.feign;

import com.github.zzay.common.core.constant.ServiceConstant;
import com.github.zzay.common.core.model.ResponseBean;
import com.github.zzay.news.dto.NewsDto;
import com.github.zzay.news.feign.factory.NewsServiceClientFallbackFactory;
import com.github.zzay.common.feign.config.OpenFeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author zzay
 * @className NewsServiceClient
 * @description News Service Client
 * @create 2022/06/06 15:12
 */
@FeignClient(value = ServiceConstant.USER_SERVICE,
        configuration = OpenFeignConfig.class,
        fallback = NewsServiceClientFallbackFactory.class)
public interface NewsServiceClient {

    /**
     * 根据新闻 id 获取新闻
     *
     * @param ids ids
     * @return 包含用户详细信息列表的响应 Bean
     */
    @RequestMapping(value = "/news/findById", method = RequestMethod.POST)
    ResponseBean getNewsById(@RequestBody Long[] ids);

    /**
     * 查询新闻数量
     *
     * @param newsDto newsDto
     * @return 包含新闻数量的响应 Bean
     */
    @RequestMapping(value = "/news/getCount", method = RequestMethod.POST)
    ResponseBean getNewsCount(@RequestBody NewsDto newsDto);

    /**
     * 添加新闻
     *
     * @param newsDto newsDto
     * @return 包含请求处理结果的响应 Bean
     */
    @PostMapping("/news/create")
    ResponseBean createNews(@RequestBody NewsDto newsDto);

    /**
     * 删除新闻
     *
     * @param newsDto newsDto
     * @return 包含请求处理结果的响应 Bean
     */
    @PostMapping("/news/delete")
    ResponseBean deleteNews(@RequestBody NewsDto newsDto);

    /**
     * 编辑新闻
     *
     * @param newsDto newsDto
     * @return 包含请求处理结果的响应 Bean
     */
    @PostMapping("/news/edit")
    ResponseBean editNews(@RequestBody NewsDto newsDto);

    /**
     * 审核新闻
     *
     * @param newsDto newsDto
     * @return 包含请求处理结果的响应 Bean
     */
    @PostMapping("/news/audit")
    ResponseBean auditNews(@RequestBody NewsDto newsDto);

}
